<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link href="__ACSS__/css1.css" rel="stylesheet" type="text/css">
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/ueditor/ueditor.all.min.js"> </script>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/ueditor/lang/zh-cn/zh-cn.js"></script>
<script language='javascript' src='__AJS__/public.js'></script>

<import type='js' file='Admin.Js.jquery'/>
<script>
	
	$().ready(function(){
		//在线编辑器
    var ue = UE.getEditor('editor');
  
		//分类信息二级联动
		createCate();
		//验证名称
		check_gname();
		//验证货号
		checksn();
		//提交时验证所有的信息	
		btnOk();
		
	});
	function createCate(){
		var data={
			c_parent_id:0
		}
		//将获取的数据添加到选项中
		$.post('__GROUP__/Category/createCate',data,function(msg){
				$(msg.data).each(function(i,item){
					var op=new Option(item.c_name,item.c_id);
					$('#createCate')[0].options.add(op);
				});
		},'json');
		
		$('#createCate').bind('change',function(){
			
			$('#Cate').empty();
						
			var c_parent_id=$('#createCate').val();
			
			var data={
			c_parent_id:c_parent_id
		}
	
		
		$.post('__GROUP__/Category/createCate',data,function(msg){
				$(msg.data).each(function(i,item){
					var op=new Option(item.c_name,item.c_id);
					
					$('#Cate')[0].options.add(op);
				});
		},'json');
		});
	}

		//验证用户名的合法性
		function check_gname(){
			$('#g_name').bind('blur',function(){
			var g_name=$('#g_name').val();
		var reg = eval('/^[^%{};$!！￥@#*()><?+~&]{1,}$/gi');
		var reg1 = eval('/^.{4,15}$/gi');
		//判断字符串中是否有指定模式匹配的字符或字符串  返回Boolbean
		 flg=reg.test(g_name);
		flg1=reg1.test(g_name);

		$('#name').css('color','red');
		if(!flg1){
			$('#name').html('商品名称长度范围为4至15个!');
		}
		 if (!flg) {
		 	
		 	$('#name').html('商品名称不允许包含%、$、!、@、#等特殊字符!');
		
		 }
		 if(g_name==''){
		 	$('#name').html('商品名称不可以为空!');			
			
		 }
		 //var name1=$('#name').html();
		 //if(name1 !=''){
				//$(':submit').attr('disabled','true');
			//}
		 
		});
		$('#g_name').bind('focus',function(){
			$('#name').html('');
		});
		
		}
		
		function checksn(){
		
		$('#sn').bind('blur',function(){
			var sn=$('#sn').val();
		var reg = eval('/^[0-9a-zA-Z]*$/gi');
		
		//判断字符串中是否有指定模式匹配的字符或字符串  返回Boolbean
		 flg=reg.test(sn);
		
		$('#sn_cuo').css('color','red');
		 if (!flg) {
		 	
		 	$('#sn_cuo').html('货号不允许有中文!');
		
		 }
		 //if(sn==''){
		 	//$('#sn_cuo').html('货号不可以为空!');
		 //}
		 	//var sn1=$('#sn_cuo').html();
		 //if(sn1 !=''){
				//$(':submit').attr('disabled','true');
			//}
		});
		$('#sn').bind('focus',function(){
			$('#sn_cuo').html('');
			
			
		});		
		}
			//提交验证
		function btnOk(){
			$(':submit').bind('mouseover',function(){
			
				if ($('#name').html() != '') {
				
						alert('不正确的信息为：'+$('#name').html());	
				}
				if($('#sn_cuo').html() != ''){
					alert('不正确的信息为：'+$('#sn_cuo').html());	
				}
		});	
		
		}

</script>
</head>

<SCRIPT language=javascript>
	
</SCRIPT>
<h1>
<span class="action-span1"><a href="">SHOP 管理中心</a> </span><span id="search_id" class="action-span1"> - 添加商品信息 </span>
<div style="clear:both"></div>
</h1>

<body>
<form method="POST" action="__GROUP__/Goods/insert" enctype="multipart/form-data">
	
<table class="table" cellspacing="1" cellpadding="2" width="99%" align="center" 
border="0">
  <tbody>
    <tr>
      <th class="bg_tr" align="left" colspan="2" height="25">
    <!-- tab bar -->
	<div class="tab-div">
    <div id="tabbar-div">
      <p>
      <span class="tab-front" id="general-tab" onclick="changeTab('general')">添加商品信息</span>
      </p>
    </div>	
	</div>
      </th>
    </tr>
     <tr>
      <td class="td_bg" width="25%" height="23" align="right">所属分类：</td>
      <td width="83%" class="td_bg">
      <select name='c_parent_id' id='createCate'>
      	<option value='0'> 请选择 </option>
		
      </select>
	  <select name='c_id' id='Cate'>
      	<option value='0'> 请选择 </option>
		
      </select>
      </td>
    </tr>
	 <tr>
      <td class="td_bg" width="25%" height="23" align="right">所属品牌：</td>
      <td width="83%" class="td_bg">
      <select name='b_id' id='b_id'>
      	<option value='0'>品牌分类</option>
		<volist name='data1' id='vo'>
			<option value='{$vo.b_id}'>{$vo.b_name}</option>
		</volist>
      </select>
      </td>
    </tr>
    <tr>
      <td class="td_bg" width="25%" height="23" align="right">商品名称：</td>
      <td width="83%" class="td_bg">
      	<input type="text" name="g_name" id='g_name' /><span class="require-field">*</span>&nbsp;&nbsp;<span id="name"></span>
      </td>
    </tr>
    <tr id="sn">
      <td class="td_bg" width="25%" height="23" align="right">商品货号：</td>
        <td width="83%" class="td_bg">
       <input type="text" id='sn'name="g_sn" value="" size="20" />&nbsp;&nbsp;<span id="sn_cuo"></span> 
	       
        </td>
    </tr>
	<tr>
      <td class="td_bg" width="20%" height="10" align="right"></td>
        <td width="83%" class="td_bg">
      <span class="require-tishi">货号如不填系统自动生成(格式:GOODSxxxxx)</span> 
	       
        </td>
    </tr>
	  <tr>
            <td class="td_bg" width="25%" height="23" align="right">售价：</td>
            <td width="83%" class="td_bg"><input type="text" name="g_price" value="1.00" size="20" onblur="priceSetted()"/><span class="require-field">*</span></td>
            
     </tr>
	  <tr>
            <td class="td_bg" width="25%" height="23" align="right">库存数量：</td>
            <td  width="83%" class="td_bg"><input type="text" name="g_inv" value="1" size="20" /><span class="require-field">*</span><br />
            </td>
          </tr>
		  <tr>
            <td class="td_bg" width="25%" height="23" align="right">加入推荐：</td>
            <td  width="83%" class="td_bg">
                <input type="checkbox" name="g_is_new" value="1"  />新品
                <input type="checkbox" name="g_is_hot" value="1"  />热销
            </td>
          </tr>
		    <tr>
            <td class="td_bg" width="25%" height="23" align="right">上架：</td>
            <td width="83%" class="td_bg"><input type="checkbox" name="g_is_sale" value="1"/> 打勾表示允许销售，否则不允许销售。</td>
          </tr>
    <tr>
      <td class="td_bg" width="25%" height="23" align="right">商品描述：</td>
      <td width="83%" class="td_bg">
      	<textarea name='g_desc' id='editor' rows='4' cols='80'></textarea>
	
      </td>
    </tr>
	<tr>
      <td class="td_bg" width="25%" height="23" align="right">排序：</td>
      <td width="23%" class="td_bg">
      	<input type="text" name="g_sort" id='name' />
      </td>
    </tr>
	  <tr>
            <td class="td_bg" width="25%" height="23" align="right">上传商品图片：</td>
            <td width="23%" class="td_bg">
              <input   type="file" name="g_img" size="35" />
            </td>
          </tr>
    <tr>
      <td class="td_bg" width="25%" height="23"></td>
      <td class="td_bg" width="83%">
      	<input type="submit" name="submit" value="添加"/><input type="hidden" name="hidden"/>
      </td>
    </tr>
  </tbody>
</table>
</form>
</body>
</html>
